function  masterfile_cpu(file,seconds)
if nargin < 2, seconds = 0; end
if seconds == 0
    [y, Fs] = wavread(file);      % data= y, sampling freq = Fs
else
    [y, Fs] = wavread(file,[1 44100*seconds]);      % data= y, sampling freq = Fs
end


beatdetectionon = true;

player = audioplayer(y,Fs);

y = y(:,1)*10;


%y = gsingle(y);
lenY = length(y);
lengthSong = lenY/Fs;




timeToJump = 2.2;
timeSkip = 350/44100;
goodTill = 0;
val = [];

g1max=1;
g2max=1;
g3max=1;

[xs,ys,zs] = sphere(10);


%%%%%%

lastGoodTime = 0;



time = 0;
play(player);

myt = tic;
while time<lengthSong
    
    time = toc(myt);
    
    indnew = [ceil((time-timeSkip)*44100) ceil((time+timeSkip)*44100)];
    
    if (indnew(1) <= 0)
        indnew(1) = 1;
    end
    if (indnew(2) >= lenY)
        indnew(2)= lenY;
    end
    ind = [indnew(1):indnew(end)];
    if length(ind) == 0
        break;
    end
    startFrame = ceil(time*44100);
    endFrame = ceil((time+2.2)*44100);
    
    if beatdetectionon
        if (or((goodTill <= time),(goodTill-time) < .5)) %testing if we're past the last analyzed point, or close to it, .5s
            if (lengthSong - time > timeToJump)
                output = filterbank(y(startFrame:endFrame));
                output = hwindow(output);
                lastGoodTime = time;
            else
                output = filterbank(y((ceil((lengthSong - timeToJump)*44100):ceil((lengthSong)*44100))));
                output = hwindow(output);
                lastGoodTime = time;
                
            end
            
            subplot(2,2,2);
            
            upperlimit = ones(1, 1)*g2max; %upperlimit
            
            plot(upperlimit);
            hold on;
            plot(upperlimit*0); %lower limit
            
            for i=1:6
                c =abs(output(:,i));
                                saveForLater = c;

                c = c/max(c);
                plot(c);
                
            end
            hold off
            
        end
        
    end
    
    
    subplot(2,2,1);
    if g1max < max(y(ind))
        g1max = max(y(ind));
    end
    
    plot(y(ind)/max(abs(y(ind)))) %plotting the data
    
    
    
    %%%
    if beatdetectionon==true
        subplot(2,2,3);
        deltatime = time-lastGoodTime;
        deltaFrame = ceil(deltatime*44100);
        if deltaFrame == 0
            deltaFrame = 1;
        end
        
        maxvalues = max(saveForLater);
        tsaveForLater = saveForLater;
        for i=1:6
            tsaveForLater(:,i) =  tsaveForLater(:,i)/maxvalues(i);
        end
        
        
        
        X = [xs(:)*tsaveForLater(deltaFrame,1)]; %middle
        Y = [ys(:)*tsaveForLater(deltaFrame,1)];
        Z = [zs(:)*tsaveForLater(deltaFrame,1)];
        
        
        
        X = [X; xs(:)*tsaveForLater(deltaFrame,2)-10]; %bottom left
        Y = [Y; ys(:)*tsaveForLater(deltaFrame,2)-10];
        Z = [Z; zs(:)*tsaveForLater(deltaFrame,2)];
        
        X = [X; xs(:)*tsaveForLater(deltaFrame,3)]; %top right
        Y = [Y; ys(:)*tsaveForLater(deltaFrame,3)];
        Z = [Z; zs(:)*tsaveForLater(deltaFrame,3)-10];
        
        X = [X; xs(:)*tsaveForLater(deltaFrame,4)-10]; %top left
        Y = [Y; ys(:)*tsaveForLater(deltaFrame,4)];
        Z = [Z; zs(:)*tsaveForLater(deltaFrame,4)];
        
        X = [X; xs(:)*tsaveForLater(deltaFrame,5)-10]; %top
        Y = [Y; ys(:)*tsaveForLater(deltaFrame,5)+5];
        Z = [Z; zs(:)*tsaveForLater(deltaFrame,5)-10];
        
        
        
        X = [X; xs(:)*tsaveForLater(deltaFrame,6)]; %bottom right
        Y = [Y; ys(:)*tsaveForLater(deltaFrame,6)-10];
        Z = [Z; zs(:)*tsaveForLater(deltaFrame,6)-10];
        
        limits = 13;
        X = [X;-1*limits;1*limits]; %limits
        Y = [Y;-1*limits;1*limits];
        Z = [Z;-1*limits;1*limits];
        scatter3(X(:),Y(:),Z(:))
        %%%
        
        subplot(2,2,4)
        sumsaveForLater = zeros(1,6);
        for i=1:6
            sumsaveForLater(i) =sumsaveForLater(i)+ tsaveForLater(deltaFrame,i) ;
        end
        sumsaveForLater = sumsaveForLater/max(sumsaveForLater);
        X = [xs(:)*sumsaveForLater(1)]; %middle
        Y = [ys(:)*sumsaveForLater(1)];
        Z = [zs(:)*sumsaveForLater(1)];
        
        limits = 1;
        X = [X;-1*limits;1*limits]; %limits
        Y = [Y;-1*limits;1*limits];
        Z = [Z;-1*limits;1*limits];
        scatter3(X(:),Y(:),Z(:))
        
        
    end
    
    pause(.01);
    
    
    val = [val toc];
    mean(val)
end
